package com.opgea.crm.domain.entities.security;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;


@Entity
@Table(name="authorities")
public class Authority {

	@Id
	@Column(name="authority")
	private String Authority;
	
	@OneToOne
	@JoinColumn(name="username", referencedColumnName="username")
	private CrmUser users;

	public String getAuthority() {
		return Authority;
	}

	public void setAuthority(String authority) {
		Authority = authority;
	}

	public CrmUser getUsers() {
		return users;
	}

	public void setUsers(CrmUser users) {
		this.users = users;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result
				+ ((Authority == null) ? 0 : Authority.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Authority other = (Authority) obj;
		if (Authority == null) {
			if (other.Authority != null)
				return false;
		} else if (!Authority.equals(other.Authority))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "Authorities [Authority=" + Authority + ", users=" + users + "]";
	}
	
	
}
